import 'package:flutter/material.dart';
import 'package:osc/ui/dialog/loading_dialog.dart';

class BaseLoadingWidget{
  final BuildContext context;
  BaseLoadingWidget(this.context);

  bool isShowingDialog = false;
  showLoadingDialog(String msg){
    if(isShowingDialog){
      return;
    }
    isShowingDialog = true;
    showDialog<Null>(
        context: context, //BuildContext对象
        barrierDismissible: false,
        builder: (BuildContext context) {
          return new LoadingDialog(
              dismissDialogEvent: null,
          );
        });
  }

  dismissLoadingDialog(){
    if(isShowingDialog){
      isShowingDialog = false;
      Navigator.pop(context);
    }
  }
}